<template>
<div>
  <el-menu
      :default-active="this.$store.state.menu.editableTabsValue"
      class="el-menu-vertical-demo"
      background-color="#545c64"
      text-color="#fff"
      active-text-color="#ffd04b">
    <router-link to="/index">
      <el-menu-item index="Index" @click="changeTab({component:'Index',name:'首页'})">
        <template slot="title">
          <i class="el-icon-s-home"></i>
          <span slot="title">首页</span>
        </template>
      </el-menu-item>
    </router-link>


    <el-submenu :index="item.component" v-for="item in menuList" :key="item.id">
      <template slot="title">
        <i :class="item.icon"></i>
        <span v-text="item.name"></span>
      </template>
      <router-link :to="{name:'Sys'+children.component}" v-for="children in item.children" :key="children.id">
      <el-menu-item :index="children.component" @click="changeTab(children)">
        <template slot="title">
          <i :class="children.icon"></i>
          <span slot="title" v-text="children.name"></span>
        </template>
      </el-menu-item>
      </router-link>
    </el-submenu>


  </el-menu>
</div>
</template>

<script>
export default {
  name: "SideMenu",
  data(){
    return{

    }
  },
  computed:{
    menuList:{
      get(){
        return this.$store.state.menu.menuList
      }
    }
  },
  methods:{
    changeTab(children){
      this.$store.commit('addTab',children)
    }
  }
}
</script>

<style scoped>
.el-menu-vertical-demo{
  height: 100vh;
  text-align: left;
}
a{

  text-decoration:none;
}
</style>